﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using MyCalManager.Data;
using MyCalManager.Model;

namespace MyCalManager.Helper
{

    public static class Extensions
    {
        public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> coll)
        {
            var c = new ObservableCollection<T>();
            foreach (var e in coll)
                c.Add(e);
            return c;
        }

        public static Breakfast ToBreakfastItem(this FoodItem item)
        {
            var c = new Breakfast();
            c.ID = item.ID;
            c.Item = item.Item;
            c.Kal = item.Kal;
            c.Kh = item.Kh;
            c.Menge = item.Menge;
            c.WWPoints = item.WWPoints;
            c.Eiweiss = item.Eiweiss;
            c.Fett = item.Fett;

            return c;
        }

        public static Uri EnumToURI(this NavigateTo Item)
        {
            switch (Item)
	        {
		        case NavigateTo.Main:
                    return new Uri("View/MainContent.xaml", UriKind.RelativeOrAbsolute);
                case NavigateTo.User:
                    return new Uri("View/UserView.xaml", UriKind.RelativeOrAbsolute);
                case NavigateTo.Statistik:
                    return new Uri("View/StatistikView.xaml", UriKind.RelativeOrAbsolute);
                case NavigateTo.NewDay:
                    return new Uri("View/NewDay.xaml", UriKind.RelativeOrAbsolute);
                default:
                    return null;
	        }

        }

       

        public static Lunch ToLunchItem(this FoodItem item)
        {
            var c = new Lunch();
            c.ID = item.ID;
            c.Item = item.Item;
            c.Kal = item.Kal;
            c.Kh = item.Kh;
            c.Menge = item.Menge;
            c.WWPoints = item.WWPoints;
            c.Eiweiss = item.Eiweiss;
            c.Fett = item.Fett;

            return c;
        }

        public static Dinner ToDinnerItem(this FoodItem item)
        {
            var c = new Dinner();
            c.ID = item.ID;
            c.Item = item.Item;
            c.Kal = item.Kal;
            c.Kh = item.Kh;
            c.Menge = item.Menge;
            c.WWPoints = item.WWPoints;
            c.Eiweiss = item.Eiweiss;
            c.Fett = item.Fett;

            return c;
        }

        public static Else ToElseItem(this FoodItem item)
        {
            var c = new Else();
            c.ID = item.ID;
            c.Item = item.Item;
            c.Kal = item.Kal;
            c.Kh = item.Kh;
            c.Menge = item.Menge;
            c.WWPoints = item.WWPoints;
            c.Eiweiss = item.Eiweiss;
            c.Fett = item.Fett;

            return c;
        }

        public static decimal dreisatz(decimal a, decimal b)
        {
            return (a * b) / 100;
        }

        public static decimal dreisatz(decimal a, decimal b, decimal origMenge)
        {
            return Math.Round((a * b) / origMenge, 2);
        }

       
    }
}
